﻿using HML.Design;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;

namespace HML
{
    /// <summary>
    /// ImageSlide标题栏
    /// </summary>
    [TypeConverter(typeof(PropertyOrderConverter))]
    public class ImageSlideTitleBar
    {
        #region 属性

        private bool visible = true;
        /// <summary>
        ///是否显示
        /// </summary>
        [Description("是否显示")]
        [PropertyOrder(-200)]
        [DefaultValue(true)]
        public bool Visible
        {
            get { return this.visible; }
            set
            {
                if (this.visible == value)
                    return;

                this.visible = value;
                this.Invalidate();
            }
        }

        private int padding = 4;
        /// <summary>
        ///内边距
        /// </summary>
        [Description("内边距")]
        [PropertyOrder(-199)]
        [DefaultValue(4)]
        public int Padding
        {
            get { return this.padding; }
            set
            {
                if (this.padding == value)
                    return;

                this.padding = value;
                this.Invalidate();
            }
        }

        private Color borderColor = Color.FromArgb(130, 128, 128, 128);
        /// <summary>
        /// 边框颜色
        /// </summary>
        [Description("边框颜色")]
        [PropertyOrder(-198)]
        [DefaultValue(typeof(Color), "130, 128, 128, 128")]
        [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
        public Color BorderColor
        {
            get { return this.borderColor; }
            set
            {
                if (this.borderColor == value)
                    return;

                this.borderColor = value;
                this.Invalidate();
            }
        }

        private Color backColor = Color.FromArgb(100, 128, 128, 128);
        /// <summary>
        ///背景颜色
        /// </summary>
        [Description("背景颜色")]
        [PropertyOrder(-197)]
        [DefaultValue(typeof(Color), "100, 128, 128, 128")]
        [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
        public Color BackColor
        {
            get { return this.backColor; }
            set
            {
                if (this.backColor == value)
                    return;

                this.backColor = value;
                this.Invalidate();
            }
        }

        private Color textColor = Color.White;
        /// <summary>
        ///文本颜色
        /// </summary>
        [Description("文本颜色")]
        [PropertyOrder(-196)]
        [DefaultValue(typeof(Color), "White")]
        [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
        public Color TextColor
        {
            get { return this.textColor; }
            set
            {
                if (this.textColor == value)
                    return;

                this.textColor = value;
                this.Invalidate();
            }
        }

        private Font textFont = (Font)Control.DefaultFont.Clone();
        /// <summary>
        /// 文本字体
        /// </summary>
        [Description("文本字体")]
        [PropertyOrder(-194)]
        [DefaultValue(typeof(Font), "宋体,9pt")]
        public Font TextFont
        {
            get { return this.textFont; }
            set
            {
                if (this.textFont == value)
                    return;

                this.textFont = value;
                this.Invalidate();
            }
        }

        #endregion

        #region 字段

        private ImageSlide owner = null;

        #endregion

        public ImageSlideTitleBar(ImageSlide owner)
        {
            this.owner = owner;
        }

        #region 私有方法

        /// <summary>
        /// 刷新控件
        /// </summary>
        private void Invalidate()
        {
            if (this.owner != null)
            {
                this.owner.Invalidate();
            }
        }

        #endregion
    }

}
